﻿using Lib.Data.Enumeration;
using System;
using System.Reflection;
using System.Text.Json.Serialization;

namespace Lib.Data.Entitys; 
/// <summary>
/// 
/// </summary>
internal class Column  {
    /// <summary>
    /// 构造函数
    /// </summary>
    public Column() {
        this.Renewable = true;
    }
    /// <summary>
    /// 属性名称
    /// </summary>
    public string Key { get; set; }
    /// <summary>
    /// 属性类型
    /// </summary>
    [JsonIgnore]
    public Type Type { get; set; }
    /// <summary>
    /// 属性分类
    /// </summary>
    public PropertyType PropertyType { get; set; }
    /// <summary>
    /// 字段名称（字母）
    /// </summary>
    public string Name { get; set; }
    /// <summary>
    /// 字段别名
    /// </summary>
    public string Alias { get; set; }
    /// <summary>
    /// 字段标题
    /// </summary>
    public string Title { get; set; }
    /// <summary>
    /// 默认值
    /// </summary>
    public object Value { get; set; }
    /// <summary>
    /// 数据类型
    /// </summary>
    public DataType DataType { get; set; }
    /// <summary>
    /// 小数位数
    /// </summary>
    public int Size { get; set; }
    /// <summary>
    /// 字符串最小长度（0.不限制）
    /// </summary>
    public int MinLength { get; set; }
    /// <summary>
    /// 字符串最大长度（0.不限制）
    /// </summary>
    public int MaxLength { get; set; }

    /// 是否数字类型（包括整数、小数、浮点数）
    /// </summary>
    public bool IsNumber { get; set; }
    /// <summary>
    /// 是否主键
    /// </summary>
    public bool IsPrimaryKey { get; set; }
    /// <summary>
    /// 是否可空类型
    /// </summary>
    public bool IsNullable { get; set; }
    /// <summary>
    /// 外键关联表主键字段名，默认为“ID”
    /// </summary>
    public string ForeignKey { get; set; }
    /// <summary>
    /// 外键关联表实体类型
    /// </summary>
    [JsonIgnore]
    public Type EntityType { get; set; }
    /// <summary>
    /// 外键关联表名
    /// </summary>
    public string Table { get; set; }
    /// <summary>
    /// 外键关联视图名
    /// </summary>
    public string View { get; set; }
    /// <summary>
    /// 是否可更新（默认可更新）
    /// </summary>
    public bool Renewable { get; set; }
    /// <summary>
    /// <summary>
    /// 是否必填字段
    /// </summary>
    public bool Required { get; set; }
    /// <summary>
    /// 是否自增字段
    /// </summary>
    public bool AutoPrimaryKey { get; set; }
    /// <summary>
    /// 是否虚拟字段
    /// </summary>
    public bool Virtual { get; set; }
    /// <summary>
    /// 是否时间戳属性
    /// </summary>
    public bool TimeStamp { get; set; }
    /// <summary>
    /// 属性对象
    /// </summary>
    [JsonIgnore]
    public PropertyInfo That { get; set; }
    /// <summary>
    /// 序号（前端应用）
    /// </summary>
    public int Index { get; set; }

}
